package com.tangcco.lockwell.service.impl;

import com.tangcco.lockwell.domain.MessageLikesRecord;
import com.tangcco.lockwell.repository.MessageLikesRecordMapper;
import com.tangcco.lockwell.service.MessageLikesRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName: MessageLikesRecordServiceImpl
 * @author yanxinping
 * @version 1.0
 * @description: TODO
 * @date 2024/12/24 9:02
 */
@Service
public class MessageLikesRecordServiceImpl implements MessageLikesRecordService {

    @Autowired
    private MessageLikesRecordMapper messageLikesRecordMapper;


    @Override
    public int addLikesRecord(int userId, int messageId) {
        MessageLikesRecord record = new MessageLikesRecord();
        record.setLikesUserId(userId);
        record.setMessageId(messageId);
        return messageLikesRecordMapper.insertSelective(record);
    }

    @Override
    public int deleteLikesRecord(int userId, int messageId) {
        return messageLikesRecordMapper.deleteByMessageIdAndLikesUserId(userId, messageId);
    }

    @Override
    public List<MessageLikesRecord> getLikesRecord(MessageLikesRecord messageLikesRecord) {
        return messageLikesRecordMapper.selectByMessageIdAndLikesUserId(messageLikesRecord);
    }
}
